//
//  UITextField+mmjExtension.m
//  Social
//
//  Created by seirra on 2018/5/15.
//  Copyright © 2018年 mmj. All rights reserved.
//

#import "UITextField+mmjExtension.h"

static NSString*const mmjplaceholderLabeltextColor = @"placeholderLabel.textColor";

@implementation UITextField (mmjExtension)

-(void)setPlachholderColor:(UIColor *)plachholderColor{
    //提前设置占位文字，目的：让他提前创建placeholder
    NSString*oldplaceholder = self.placeholder;
    self.placeholder = @" ";
    self.placeholder = oldplaceholder;
    
    if (plachholderColor == nil) {//恢复到默认的占位文本颜色
        plachholderColor = [UIColor colorWithRed:0 green:0 blue:0.0980392 alpha:0.22];
    }
    //设置真正的占位文本颜色
    [self setValue:plachholderColor forKeyPath:mmjplaceholderLabeltextColor];
}

//-(void)setPlachholderColor:(UIColor *)plachholderColor{
//    //提前设置占位文字，目的：让他提前创建placeholder
//    if (self.placeholder.length == 0) {
//        self.placeholder = @" ";
//    }
//
//    [self setValue:plachholderColor forKeyPath:mmjplaceholderLabeltextColor];
//}

-(UIColor *)plachholderColor{
    return [self valueForKey:mmjplaceholderLabeltextColor];
}
@end
